﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Jskit XPath Tester</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../main.css" >
<script src="../../release/jskit.core.js"></script>
    <script src="../JskitConfig_doc.js"></script>

<style>
	.result_title{
		color:#008800;
		height:30px;
	}
	.result_content{
		line-height:24px;
	}
</style>
<script>

function TestXPath(){
	var doc = jskitXml.loadXml($$("#txt_Xml").value.trim());
	var xpath = $$("#txt_Xpath").value;
	var showBox = $$("#lab_Result");
	var str = "";
	try{
		var nl = doc.selectNodes(xpath);
		if(nl==null){
			str = "<div class='result_title'>Find nothing</div>";
		}else if(nl.length==1){
			str = "<div class='result_title'>Find 1 Node</div>";
			str += "<div class='result_content'>"+nl[0].xml.replace(/</gi,"&lt;")+"</div>";
		}else{
			str = "<div class='result_title'>Find "+nl.length+" Nodes</div>";
			for(var i=0;i<nl.length;i++){
				str += "<div class='result_content'>"+(i+1)+":"+nl[i].xml.replace(/</gi,"&lt;")+"</div>";
			}
		}
		showBox.innerHTML = str;
	}catch(e){
		showBox.innerHTML = e.message;
	}
}
</script>
</HEAD>

<BODY>
<div>
<table>
	<tr>
		<td class="Package">
			XPath Tester
		</td>
	</tr>
	<tr>
		<td class="content">
			
		</td>
	</tr>
</table>
<table>
	<tr>
		<td valign="top"  class="content">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>XML 文档：</td>
				</tr>
				<tr>
					<td valign="top">
						<textarea id="txt_Xml" style="width:400px;height:400px;">
<?xml version="1.0" encoding="utf-8" ?>
<root>
    <aaa id="a1" />
    <bbb id="b1" >
        <bb2 />
        <bb3 />
        <bb4 />
    </bbb>
    <ccc id="c1">
        <aaa id="c1-a1" />
        <bbb id="c1-b1" />
    </ccc>
</root>
						</textarea>
					</td>
					<td>&nbsp;</td>
					<td valign="top">
						<div><textarea id="txt_Xpath" style="width:400px;height:100px;">//aaa</textarea></div>
						<div style="text-align:center"><input type="button" onclick="TestXPath()" value="Test" /></div>
						<div id="lab_Result" style="padding:5px 5px 5px 5px;width:400px;height:270px;border:1px solid #cccccc;background-color:#ffffd0"></div>
					</td>
				</tr>
			</table>
		</td>
		<td>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center">
			
		</td>
	</tr>
</table>
</div>
</BODY>
</HTML>
